##! /bin/bash
#! bash
#
#  $Id: a_traduire_wget.sh 3 2010-05-27 16:25:49Z alistair.mills@btinternet.com $
#
export TARGET='Articles de La Guinguette &agrave; traduire'
export  total=0
. ./defines.sh

export   date=`date +'%A %d %B %Y'`
export   last=.last/

### Main script stars here ###
# Store file name  here
FILE=$1
export prepare='<font color="#a0a0a0"> On la pr&eacute;pare </font>'
  . ./defines.sh
  . ./keys.sh

while read year mon cat size url key trans line
do

  if [ "$line" != "$title_line" -a "$year" != "$comment_line" ]
  then
      . ./categories.sh
      . ./months.sh
      . ./translators.sh
      export tra=${year}_${mon}_${cat}
      if [ "$line" != "" ]
      then
        export       total=`expr $total + 1`
        export         tot=`printf '%.3i' $total`
        echo $tot - $line
        wget -nv $url
        mv index.html             ${tra}_out.htm
        sed -f ascii_to_html.ed < ${tra}_out.htm > ${tra}_out2.htm
        export wc=`wc -l ${tra}_out2.htm`
        export WC=`echo $wc | sed 's/ .*//'`
        export tp=`expr $WC - 24`
        export md=`expr $WC - 24 - 98`
        head -$tp ${tra}_out2.htm | tail -$md > ${tra}_fr.htm
#        rm                        ${tra}_out.html
      fi
  fi
done < $FILE

#
#
#
